package com.shelpe.services.sinbad.entity.mongo;

import java.util.Date;

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;

import com.shelpe.services.sinbad.entity.jpa.User;

import lombok.Data;

@Data
@Document(collection = "balance_or_realtimeCost_error_logs")
public class BalanceAndRealtimeCostErrorLog {
	@Id
	private String id;
	@Indexed
	private long userID;
	@Indexed
	private String nick;
	@Indexed
	private Date executeTime;
	@Indexed
	private String subCode;
	@Indexed
	private String subMessage;
	private String errorCode;

	public void from(User user) {
		this.userID = user.getUserID();
		this.nick = user.getNick();

		this.executeTime = new Date();
		this.id = this.userID + "_" + this.executeTime.getTime();
	}
}
